home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
3_0
/
DOUBLEDE
/
EXITADDR.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-06-22
|
3KB
|
93 lines
#include <MacTypes.h>
#include <OSUtil.h>
#include <WindowMgr.h>
#include <EventMgr.h>
#include <DialogMgr.h>
#define ETSTrapNum 0x1F4
showexitaddress()
{
WindowPtr w;
Rect r;
long address;
Str255 aStr;
long timer;
SetRect(&r,10,30,310,78);
SetPort(w = NewWindow(0L,&r,"\p",FALSE,1,-1L,FALSE,0));
TextFont(4); TextSize(12);
ShowWindow(w);
strcpy(aStr,"ExitToShell() = $");
address = NGetTrapAddress(ETSTrapNum,ToolTrap);
drawhex(&address,&aStr[strlen(aStr)],4,0);
MoveTo(r.left+(r.right-r.left-TextWidth(aStr,0,strlen(aStr)))/2,24);
DrawText(aStr,0,strlen(aStr));
strcpy(aStr,"(click mouse to continue)");
MoveTo(r.left+(r.right-r.left-TextWidth(aStr,0,strlen(aStr)))/2,36);
DrawText(aStr,0,strlen(aStr));
timer = TickCount()+300L;
while(Button());
while( !Button() && (timer > TickCount()) );
while(Button());
DisposeWindow(w);
FlushEvents(mDownMask,0);
}
/**************************** drawhex *****************************
srcPtr address in memory, ie, &alongVariable or &anInt
dstPtr (char *), with sufficient memory already allocated
numBytes number of bytes to convert, ie, for a long, the
value of 4 would normally be passed
pad pass 1 if you want "AAAA AAAA",
or 0 if you want "AAAAAAAA"
*********************************************************************/
drawhex(srcPtr,dstPtr,numBytes,pad)
char *srcPtr;
char *dstPtr;
int numBytes;
int pad;
{
asm{
movem.l A3-A4/D3-D4,-(SP)
move.w pad,D4 ;do we pad every two bytes?
move.w numBytes,D2 ;D2 = number of bytes to convert
move.l dstPtr,A0 ;A0 -> destination area
move.l srcPtr,A3 ;A3 -> source area
move.w #0,D3 ;loop counter
lea @thedata,A1 ;A1 -> hex digits table
@loop
move.b (A3)+,D0 ;copy src-> into D0, increment src->
move.b D0,D1 ;D1 = byte to convert
andi.w #15,D1 ;mask off high nibble
move.b 0(A1,D1.w),1(A0) ;copy D1th item in table to A0+1->
move.b D0,D1 ;fresh copy of D0 for high nibble
lsr.w #4,D1 ;move high nibble -> low nibble
move.b 0(A1,D1.w),0(A0) ;copy D1th item in table to A0->
addi #2,A0 ;increment A0
cmpi #0,D4 ;do we pad the string?
beq @nopadding
addi #1,D3 ;increment loop counter
btst #0,D3 ;is loop counter even?
bne @nopadding ;no, it is even, so...
move.b #0x20,(A0)+ ;pad output with a space, incr dst->
@nopadding
subi #1,D2 ;decrement byte count
bne @loop ;loop if not
move.b #0,(A0) ;C string terminator character
movem.l (SP)+,A3-A4/D3-D4 ;restore registers
return
@thedata
dc.b '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
}
}